/*
 * vga.h
 *
 * Creado: 27/11/12
 * Autor: Pablo Manuelli
 * 
 * Funciones de VGA
 *  
 */

#ifndef __VGA_H__
#define __VGA_H__

#include <types.h>
#include <om.h>

/* Colores */

#define BLACK			0x0

#define BLUE			0x1
#define GREEN			0x2
#define CYAN			0x3
#define RED				0x4
#define MAGENTA			0x5
#define BROWN			0x6

#define LIGHT_GRAY		0x7
#define DARK_GRAY		0x8

#define LIGHT_BLUE		0x9
#define LIGHT_GREEN		0xA
#define LIGHT_CYAN		0xB
#define LIGHT_RED		0xC
#define LIGHT_MAGENTA	0xD
#define LIGHT_YELLOW	0xE

#define WHITE			0xF

/* Caracteres especiales */

#define NULL_CHAR		0x0

/* Valores */

#define SCREEN_CHAR_SIZE 	2
#define SCREEN_CANT_COLUMN	80
#define SCREEN_CANT_FILAS	25
#define SCREEN_LINE_SIZE	(SCREEN_CANT_COLUMN * SCREEN_CHAR_SIZE)

/* Direcciones */

#define SCREEN_ADDR_START 	OM_VGA_PHYS_ADDR_START
#define SCREEN_ADDR_END		(SCREEN_ADDR_START + SCREEN_CANT_COLUMN * SCREEN_CANT_FILAS * SCREEN_CHAR_SIZE)

/* Registros controlador de VGA */

#define VGA_CONTROLLER_CTRL_REGISTER		0x3D4
#define VGA_CONTROLLER_DATA_REGISTER		0x3D5

#define VGA_INSTRUCION_SET_HIGH_BYTE		0xE
#define VGA_INSTRUCION_SET_LOW_BYTE			0xF

/* Funciones */

void vga_init();
void vga_set_cursor(uint_32 row, uint_32 column);
void vga_refresh_screen();
void vga_refresh_cursor();
void vga_clrln();
void vga_clrscr();
void vga_scroll_down();
void vga_set_char_color(uint_8 color);
void vga_set_scrn_color(uint_8 color);

void vga_putc(char c);
void vga_putc_rc(uint_32 row, uint_32 column, char c);

uint_32 vga_write(char* string);
uint_32 vga_write_rc(uint_32 row, uint_32 column, char* string);

uint_32 vga_printf(char* string, ... );
uint_32 vga_printf_rc(uint_32 row, uint_32 column, char* string, ... );

#endif /* __VGA_H__ */

